package com.ludomancy.starwave;

import java.util.Comparator;

public class ShipOwnerComparator implements Comparator
{
	public int compare(Object o1, Object o2)
	{
		Ship ship1 = (Ship) o1;
		Ship ship2 = (Ship) o2;
		if (ship1.owner == ship2.owner)
		{
			if(ship1.px < ship2.px)
			{
				return 1 * ship1.owner.direction;
			}
			else
			if(ship1.px == ship2.px)
			{
				return 0;
			}
			else
			{
				return -1 * ship1.owner.direction;
			}
		}
		else
		if(ship1.owner == Game.game.me)
		{
			return -1;
		}
		else
		{
			return 1;
		}
	}
}
